package com.CST.service.impl.zx;

import com.CST.entity.zx.ZXAllocation;
import com.CST.entity.zx.ZX_Project;
import com.CST.mapper.cst.zx.ZX_AllocationMapper;
import com.CST.mapper.cst.zx.ZX_ProjectInfoMapper;
import com.CST.service.zx.IZX_AllocationService;
import com.CST.service.zx.IZX_ProjectInfoService;
import com.CST.util.ExcelTransfer;
import com.CST.vo.zx.AllocationVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
public class ZX_AllocationImp  extends ServiceImpl<ZX_AllocationMapper, ZXAllocation>  implements IZX_AllocationService {

    @Autowired
    ZX_AllocationMapper allocationMapper;

    @Autowired
    IZX_ProjectInfoService projectInfoService;
    @Override
    public List<AllocationVo> getAllocationList(String financialCode) {
        return allocationMapper.getAllocationList(financialCode);
    }

    @Override
    public void deleteByFinancialCode(String financialCode) {
         allocationMapper.deleteByFinancialCode(financialCode);
    }

    @Override
    public void insertBatchZxAllocation(List<ZXAllocation> list) {
        allocationMapper.insertBatchZxAllocation(list);
    }

    @Override
    public void importAllocation(MultipartFile file) {
        ExcelTransfer<ZXAllocation> excelTransfer = new ExcelTransfer<>();
        try {
            excelTransfer.importExcel(file, this,ZXAllocation.class);
//            projectInfoService.updateProjects();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
